import {observable,action, toJS} from 'mobx';
import {Tools,Bubble} from 'weaver-mobile';
import * as API from '../../api/statistical';

const getLabel = Tools.getLabel;

export default class StatisticalStore {
    /********************************************************/
    @observable loading = false;
    @observable hasRight = 1;
    @observable selectKeyTop = 0;
    @observable dateParams = {};

    @observable echartsData = {};
    @observable reimburseData = {};
    @observable monthAmount = 0;


    initData = (value) =>{
        this.loading = true;

        this.getEchartsData();
        this.getReimburseData();


        this.loading = false;
    }


    getEchartsData = (value={}) =>{
        // this.loading = true;
        // API.getEchartsData(value).then( res =>{
        //     let {status,errorInfo} = res;
        //     if(status === '1'){
              
        //     }else{
        //         Bubble.error(errorInfo)
        //     }
            
        //     this.loading = false;
        // }) 
        this.echartsData = {
            type:'9',
            title:[{
                subtext: '未报销',
                left:'25%',
                bottom:10,
                textAlign: 'center',
                subtextStyle:{
                    color: '#FA5757',
                    fontSize:14,
                }
            },{
                subtext: '已报销',
                left:'75%',
                bottom:10,
                textAlign: 'center',
                
                subtextStyle:{
                    color: '#868686',
                    fontSize:14,
                }
            }],
            dataset:{
                source:[
                    ['product', '未报销', '已报销'],
                    ['住宿', 0, 500.00],
                    ['交通', 0,500.00],
                    ['通讯', 0,250],
                    ['餐饮', 0, 67.1],
                    ['油补', 0, 67.1],
                    ['其他', 0, 67.1]
                ]
            },
            series:[{
                name:'未报销',
                center:['25%', '55%'],
                label:{
                    normal:{
                        amount:'0.00'
                    }
                }
            },{
                name:'已报销',
                center:['75%', '55%'],
                label:{
                    normal:{
                        amount:'123,567.00'
                    }
                } 
            }]
        }
    }

    getReimburseData = () =>{
        this.monthAmount = '845';
        this.reimburseData = {
            type:['','住宿','餐饮','交通','通讯','通讯','通讯','通讯','通讯','通讯','通讯','通讯'],
            doneReimburse:['未报销','128','128','128','256','256','256','256','256','256','256','256'],
            doingReimburse:['已报销','128','128','128','256','256','256','256','256','256','256','256'],
            show:[true,true,false,false,true,true,true,true,true,true,true,true,true,true],
        }
    }

    setSelectKeyTop = (value = 0) =>{
        this.selectKeyTop = value;
    }

    setDateParams = (value) =>{
        this.dateParams = value;
    }

    clearData = () =>{
        this.selectKeyTop = 0;
        this.reimburseData = {};
        // this.echartsData = {};
        this.dateParams = {};
    }

}